//////////////////////////////////////////////////////////////////////////
//
// This file is a part of UKROP project.
// Copyright (c) Vladimir Gumenuk
//
// PROJECT:         Xort Custom Debug Engine
// FILE:            Expression.h
// AUTHOR:          Vladimir Gumenuk
// DATE:            4-Jan-2013
// MODIFICATIONS:
//
//////////////////////////////////////////////////////////////////////////

#pragma once

//////////////////////////////////////////////////////////////////////////
// CExpression
class ATL_NO_VTABLE CExpression :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CExpression, &CLSID_Expression>,
	public IDebugExpression2,
    public IXExpression
{
public:
	CExpression();
	virtual ~CExpression();

DECLARE_REGISTRY_RESOURCEID(IDR_EXPRESSION)

BEGIN_COM_MAP(CExpression)
	COM_INTERFACE_ENTRY(IDebugExpression2)
    COM_INTERFACE_ENTRY(IXExpression)
END_COM_MAP()

DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct();
	void FinalRelease();

    STDMETHOD(Initialize)( LPCOLESTR lpszText, IUnknown *pFramePropStack, DWORD dwStackBase, UINT nRadix );
    STDMETHOD(Evaluate)( IDebugProperty2 **ppResult );

public:
    STDMETHOD(EvaluateAsync)( EVALFLAGS dwFlags, IDebugEventCallback2 *pExprCallback );
    STDMETHOD(Abort)();
    STDMETHOD(EvaluateSync)( EVALFLAGS dwFlags, DWORD dwTimeout, IDebugEventCallback2 *pExprCallback, IDebugProperty2 **ppResult );

    string                          m_csText;
    EVALFLAGS                       m_dwFlags;
    UINT                            m_iRadix;
    DWORD                           m_dwTimeout;
    CComPtr<IDebugEventCallback2>   m_spCallback;
    BOOL                            m_bAborted;
    BOOL                            m_bAsync;
    CFramePropertyStack            *m_pFramePropStack;
    DWORD                           m_dwStackBase;      // stack base for this evaluation
};

OBJECT_ENTRY_AUTO(__uuidof(Expression), CExpression)
